package com.tengju.bff.interfaces.manage.crm.user;

import com.tengju.bff.interfaces.app.domination.vo.StarLevelNumVO;
import com.tengju.bff.interfaces.manage.crm.dashborad.facade.DashboardDominationTeamFacade;
import com.tengju.bff.interfaces.manage.crm.user.facade.CrmDominationTeamFacade;
import com.tengju.bff.interfaces.shared.ApiResponse;
import com.tengju.bff.interfaces.shared.servlet.ManageEntrance;
import com.tengju.data.domain.model.user.UserIdCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @Author: 李大仙
 * @Date: 2021/4/1 9:03 下午
 */
@Slf4j
@Validated
@RestController
@Api(tags = "总监CRM-管辖团队接口")
@ManageEntrance
@RequestMapping(value = "manage/crm/domination/team")
public class CrmDominationTeamController {

    @Autowired
    CrmDominationTeamFacade crmDominationTeamFacade;

    @ApiOperation(value = "管辖客户数", notes = "管辖客户数")
    @RequestMapping(value = "member/quantity", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ApiResponse<List<StarLevelNumVO>> memberQuantity(@RequestParam @NotNull(message = "用户idCode不能为空") Long idCode) {
        List<StarLevelNumVO> vo = crmDominationTeamFacade.memberQuantity(new UserIdCode(idCode));
        return ApiResponse.newSuccess(vo);
    }

    @ApiOperation(value = "本月新增客户数", notes = "本月新增客户数")
    @RequestMapping(value = "member/new/currentMonth/num", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ApiResponse<List<StarLevelNumVO>> memberNewNum(@RequestParam @NotNull(message = "用户idCode不能为空") Long idCode) {
        List<StarLevelNumVO> vo = crmDominationTeamFacade.memberNewNum(new UserIdCode(idCode));
        return ApiResponse.newSuccess(vo);
    }

    @ApiOperation(value = "签约中服务商", notes = "签约中服务商")
    @RequestMapping(value = "member/signing/num", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ApiResponse<List<StarLevelNumVO>> memberSigning(@RequestParam @NotNull(message = "用户idCode不能为空") Long idCode) {
        List<StarLevelNumVO> vo = crmDominationTeamFacade.signingMember(new UserIdCode(idCode));
        return ApiResponse.newSuccess(vo);
    }

    @ApiOperation(value = "即将晋升服务商", notes = "即将晋升服务商")
    @RequestMapping(value = "member/upcoming/num", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ApiResponse<List<StarLevelNumVO>> memberUpcoming(@RequestParam @NotNull(message = "用户idCode不能为空") Long idCode) {
        List<StarLevelNumVO> vo = crmDominationTeamFacade.upcomingMember(new UserIdCode(idCode));
        return ApiResponse.newSuccess(vo);
    }
}
